package com.lyrcsoft.springbootaop.controller;

import com.lyrcsoft.springbootaop.service.SessionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author fujc2dev@126.com
 * @date 2024-12-18
 */
@RestController
@RequestMapping("/test")
public class SessionController {

    @Resource
    private SessionService sessionService;

    @PostMapping("/login")
    public String login(@RequestParam String username) {

        sessionService.setSession(username);
        return "Logged in as " + username;
    }


    @GetMapping("/profile")
    public String profile() {
        // 获取会话数据

        return "Profile page for " +       sessionService.getSession();
    }

}
